home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-25 | 1020 b | 41 lines | [TEXT/CWIE] |
- // STL4.cp
- #include <iostream>
- #include <set>
-
- int main()
- {
- typedef std::set<char> MySet;
- typedef std::multiset<char> MyMultiSet;
- std::ostream_iterator<char> out(std::cout);
- std::string start("sleep is a poor substitute for caffeine");
- MySet s(start.begin(), start.end());
- MyMultiSet ms;
- ms.insert(start.begin(), start.end());
-
- std::cout << " start: ";
- std::copy(s.begin(), s.end(), out);
- std::cout << "\n start: ";
- std::copy(ms.begin(), ms.end(), out);
-
- MySet::iterator si1, si2;
- MyMultiSet::iterator msi1, msi2;
- si1 = s.lower_bound('b');
- si2 = s.upper_bound('s');
- s.erase(' ');
- s.erase(si1, si2);
- msi1 = ms.lower_bound('b');
- msi2 = ms.upper_bound('s');
- ms.erase(' ');
- ms.erase(msi1, msi2);
-
- std::cout << "\nremoved b-s: ";
- std::copy(s.begin(), s.end(), out);
- std::cout << "\nremoved b-s: ";
- std::copy(ms.begin(), ms.end(), out);
- std::cout << "\n";
- }
- // start: abcefilnoprstu
- // start: aabceeeeefffiiilnooopprrsssstttuu
- // removed b-s: atu
- // removed b-s: aatttuu
-